﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;


namespace PJ.Data.Inventory
{
    [Serializable]
    [DataContract]
    public class BaseInventoryBarCodeData : BaseEntityData, IInventoryBarCodeData
    {
        private double _Quantity;
        private string _UnitId;
        private string _OwnerId;

        public BaseInventoryBarCodeData()
        {
        }

        public override IObjectData Init(IObjectData data)
        {
            base.Init(data);
            IInventoryBarCodeData temp = (IInventoryBarCodeData)data;
            this.OwnerId = temp.OwnerId;
            this.Quantity = temp.Quantity;
            this.UnitId = temp.UnitId;
            return this;
        }

        [DataMember]
        public string OwnerId
        {
            get { return _OwnerId; }
            set { _OwnerId = value; }
        }

        [DataMember]
        public double Quantity
        {
            get { return _Quantity; }
            set { _Quantity = value; }
        }
        [DataMember]
        public string UnitId
        {
            get { return _UnitId; }
            set { _UnitId = value; }
        }
        public override IObjectData Copy(IObjectData data)
        {
            base.Copy(data);
            IInventoryBarCodeData temp = (IInventoryBarCodeData)data;
            this.OwnerId = temp.OwnerId;
            this.Quantity = temp.Quantity;
            this.UnitId = temp.UnitId;
            return this;
        }
        public override bool IsEqual(IObjectData data)
        {
            if (base.IsEqual(data))
            {
                IInventoryBarCodeData temp = (IInventoryBarCodeData)data;
                if (temp.OwnerId == this.OwnerId)
                    if (temp.Quantity == this.Quantity)
                        if (temp.UnitId == this.UnitId)
                            return true;
            }
            return false;
        }


        public override IObjectData CreateNewInstance()
        {
            return new BaseInventoryBarCodeData();
        }
    }
}
